package com.chujian.sys.entity;

import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.chujian.SystemEchoConst;
import com.chujian.framework.annotation.echo.Echo;
import com.chujian.framework.core.IId;
import com.chujian.framework.core.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * 用户角色表
 *
 * @author chujian
 * @since 2021-08-26
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@TableName("sys_role_user")
@KeySequence("sys_role_user_seq")
@ApiModel(value = "实体", description = "用户角色表")
public class SysRoleUser extends BaseEntity implements IId, Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    @TableId("role_user_id")
    private Long roleUserId;

    @ApiModelProperty(value = "角色id")
    @TableField("role_id")
    @Echo(value = SystemEchoConst.roleEchoService, targetField = "roleName")
    private Long roleId;

    @ApiModelProperty(value = "用户id")
    @TableField("user_id")
    @Echo(value = SystemEchoConst.userEchoService, targetField = "userName")
    private Long userId;

    @ApiModelProperty(value = "账套id")
    @TableField("ac_id")
    private Long acId;

    // ++++++ 系统拓展 +++++++
    @TableField(exist = false)
    private Map<String, String> query = new HashMap<>();

    @Override
    public Long getId() {
        return this.roleUserId;
    }

    @Override
    public void setId(Serializable id) {
        if (null != id) {
            this.roleUserId = Long.parseLong("" + id);
        }
    }

    // ++++++ 业务拓展 +++++++
    @TableField(exist = false)
    private String userName;

    @TableField(exist = false)
    private String roleName;

}
